

* Formatting
graph set window fontface "Times New Roman"	// use Times New Roman as the default font for Graph window
// 	 graph set window fontface default 			// use this to restore to factury setting if preferred later

set scheme s1mono


********************************************************************
*************** Prepare the data ***************
use "${ddata}cleaned_data_wACSweight.dta", clear

keep userid treatment sce state white age male college married working_ft child_under_6 child_under_18 lincome  current_censusdiv
sort userid sce

save "${ddata}data_demographics", replace



use "${ddata}cleaned_data_wACSweight.dta", clear            

forvalues i=0(1)5 {

	xtile quartile_gap_`i' = original_gap`i'		, n(4)
	xtile quartile_so_`i'  = so_mother_time_off_`i' , n(4)

	gen l_quartile_gap_`i' =  quartile_gap_`i'==1 					   if quartile_gap_`i'~=. 
	gen iqr_gap_`i'		   = (quartile_gap_`i'==2|quartile_gap_`i'==3) if quartile_gap_`i'~=.
	gen h_quartile_gap_`i' =  quartile_gap_`i'==4 					   if quartile_gap_`i'~=. 

	gen 	group_`i'=1 if l_quartile_gap_`i'==1
	replace group_`i'=2 if 		  iqr_gap_`i'==1
	replace group_`i'=3 if h_quartile_gap_`i'==1
}

keep userid sce qs2_*  group_*

reshape long qs2_ group_, i(userid sce) j(questions)
drop if qs2_==.
rename qs2_ qs2
rename group_ group


gen group1 = group==1 if group~=.
gen group2 = group==2 if group~=.
gen group3 = group==3 if group~=.

sort userid sce
merge userid sce using "${ddata}data_demographics"

forvalues i=1(1)3 {

	gen group`i'_t = group`i'*treatment

}

********************************************************************
*************** Figure A3: Mechanism (BY GENDER) ***************
************* FEMALES **********
label var group1_t "Bottom Quartile PG"
label var group2_t "Middle 50% PG "
label var group3_t "Top Quartile PG"

#delimit cr
forvalues i=0(1)5 {

	regress qs2 group1_t group2_t group3_t group1 group2 group3 if question==`i'&male==0, robust

	estimates store F`i'_f

}

#delimit;

coefplot (F1_f, keep(group1_t group2_t group3_t) mcolor(navy) ciopts(color(navy))) 
(F2_f, keep(group1_t group2_t group3_t) mcolor(maroon) ciopts(color(maroon)))
(F3_f, keep(group1_t group2_t group3_t) mcolor(orange) ciopts(color(orange)))
(F4_f, keep(group1_t group2_t group3_t) mcolor(emerald) ciopts(color(emerald)))
(F5_f, keep(group1_t group2_t group3_t) mcolor(purple) ciopts(color(purple))), 
vertical ytitle("Treatment Effect (percentage points)", size(vsmall)) 
yline(0) xlabel(,labs(small)) ylabel(,labs(small)) 
legend( rows(1) size(vsmall) subtitle("Mother earns:", size(vsmall)) label(2 "15% less") label(4 "Same") label(6 "15% more") label(8 "30% more") label(10 "50% more") ) 
title("Women", size(small)) legend(region(lstyle(none))) ;
graph save "${o}figure3_f", replace;


#delimit;
coefplot (F0_f, keep(group1_t group2_t group3_t)  bcolor(navy%40)), 
vertical recast(bar)  barwidth(0.5) fcolor(*.8)  
ytitle("Treatment Effect (percentage points)", size(small)) yline(0) 
xlabel(,labs(small)) ylabel(,labs(vsmall)) legend( off)  title("Women", size(small)) ;
graph save "${o}figure2_f", replace;

#delimit cr	


************* MALES **********
#delimit cr
forvalues i=0(1)5 {

	regress qs2 group1_t group2_t group3_t group1 group2 group3 if question==`i'&male==1, robust

	estimates store F`i'_m

}

#delimit;
coefplot (F1_m, keep(group1_t group2_t group3_t) mcolor(navy) ciopts(color(navy))) 
(F2_m, keep(group1_t group2_t group3_t) mcolor(maroon) ciopts(color(maroon)))
(F3_m, keep(group1_t group2_t group3_t) mcolor(orange) ciopts(color(orange)))
(F4_m, keep(group1_t group2_t group3_t) mcolor(emerald) ciopts(color(emerald)))
(F5_m, keep(group1_t group2_t group3_t) mcolor(purple) ciopts(color(purple))), 
vertical ytitle("Treatment Effect (percentage points)", size(vsmall)) 
yline(0) xlabel(,labs(small)) ylabel(,labs(small)) 
legend( rows(1) size(vsmall) subtitle("Mother earns:", size(vsmall)) label(2 "15% less") label(4 "Same") label(6 "15% more") label(8 "30% more") label(10 "50% more") ) 
title("Men", size(small)) legend(region(lstyle(none))) ;
graph save "${o}figure3_m", replace;


#delimit;
coefplot (F0_m, keep(group1_t group2_t group3_t)  
bcolor(navy%40)), vertical recast(bar)  barwidth(0.5) fcolor(*.8)  
ytitle("Treatment Effect (percentage points)", size(small)) 
yline(0) xlabel(,labs(small)) ylabel(,labs(vsmall)) legend( off)  title("Men", size(small)) ;
graph save "${o}figure2_m", replace;


************* Combine **********	
#delimit;

gr combine "${o}figure2_f.gph" "${o}figure2_m.gph", title("A. Scenario 1", size(small)) ;
graph export "${o}treatment_pg_q1_gender.pdf", replace;


grc1leg "${o}figure3_f.gph" "${o}figure3_m.gph", title("B. Scenario 2", size(small)) 
ycommon legendfrom("${o}figure3_f.gph");
graph export "${o}treatment_pg_q2_gender.pdf", replace;

#delimit cr		

erase "${o}figure3_f.gph"
erase "${o}figure3_m.gph"
erase "${o}figure2_f.gph"
erase "${o}figure2_m.gph"



********************************************************************
*************** Figure A4: Mechanism (w/ demographics controls) ***************
#delimit;

local demographics white age male college married working_ft child_under_6 child_under_18 lincome i.sce i.current_censusdiv;

forvalues i=0(1)5 {;

	xi: regress qs2 group1_t group2_t group3_t group1 group2 group3 `demographics' if question==`i', robust;

	estimates store F`i'_d;

};


label var group1_t "Bottom Quartile PG (Avg PG<0)";;
label var group2_t "Middle 50% PG (Avg PG~0)";
label var group3_t "Top Quartile PG (Avg PG>0)";

#delimit;
coefplot (F1_d, keep(group1_t group2_t group3_t) mcolor(navy) ciopts(color(navy))) 
(F2_d, keep(group1_t group2_t group3_t) mcolor(maroon) ciopts(color(maroon)))
(F3_d, keep(group1_t group2_t group3_t) mcolor(orange) ciopts(color(orange)))
(F4_d, keep(group1_t group2_t group3_t) mcolor(emerald) ciopts(color(emerald)))
(F5_d, keep(group1_t group2_t group3_t) mcolor(purple) ciopts(color(purple))), 
vertical ytitle("Treatment Effect (percentage points)", size(small)) 
yline(0) xlabel(,labs(small)) ylabel(,labs(small)) 
legend( rows(1) size(small) subtitle("Mother earns:", size(small)) 
label(2 "15% less") label(4 "Same") label(6 "15% more") label(8 "30% more") label(10 "50% more") ) 
title("B. Scenario 2", size(msmall))  legend(region(lstyle(none)));
graph save "${o}figure3_d", replace;
graph export "${o}treatment_by_pg_q2_d.pdf", replace;



#delimit;
coefplot (F0_d, keep(group1_t group2_t group3_t)  
color(navy%40)), vertical recast(bar)  barwidth(0.5) fcolor(*.8)  
ytitle("Treatment Effect (percentage points)", size(small)) 
yline(0) xlabel(,labs(small)) ylabel(,labs(small)) legend( off) 
title("A. Scenario 1", size(msmall))    ;
graph save "${o}figure2_d", replace;
graph export "${o}treatment_by_pg_q1_d.pdf", replace;

#delimit cr	


erase "${o}figure3_d.gph"
erase "${o}figure2_d.gph"
